{% extends 'base.html' %}
{% block head %}
    <title>新闻列表</title>
    <link href="{{ url_for('static',filename='css/model.css') }}" rel="stylesheet">
    <link href="{{ url_for('static',filename='css/index0602.css') }}" rel="stylesheet">
    <link href="{{ url_for('static',filename='css/master.css') }}" rel="stylesheet">
    <style>
        .previous{
            color: #000;
        }
        .previous:hover{
            color: #000;
        }
    .news-model{
        padding-left:15px;

    }
    .news-model a{
        font-size:15px;
    }
	</style>

{% endblock %}
{% block body %}
<!-- ##########主体########## -->
<div class="container" id="news">

		<div class="col-md-12">
			<div class="model-details-title" >
				<span>您当前的位置：</span><a href="/index" class="previous">网站首页</a><span>&nbsp;|&nbsp;</span><span>新闻通知&nbsp;</span></span>
			</div>
			 <div class="model-details" id="new_list">
                {% for i in posts %}
                <div class="news-model">
                    <a href="/news_content/{{ i.n_id }}"><b>{{ i.n_title }}</b></a><span>【{{ i.n_date.strftime("%Y-%m-%d") }}】</span>
                </div>
                {% endfor %}
            </div>
        </div>

        <div style="text-align:center;">
            <nav>
                 <ul class="pagination">
                        {#上一页#}
                            {%  if pagination.has_prev  %}
                                <li><a href="{{ url_for('.newlist',page=pagination.prev_num) }}">&laquo;</a></li>
                            {% endif %}

                            {#页码#}
                            {% set page_now = pagination.page  %}
                            {% set page_count = pagination.pages %}
                            {% if pagination.pages <= 5 %}
                                {% for p in pagination.iter_pages() %}
                                        {% if p == pagination.page %}
                                          <li ><a style="background-color: #005197;color: #fff;" href="{{ url_for('.newlist',page=p) }}">{{ p }}</a></li>
                                        {% else %}
                                            <li ><a href="{{ url_for('.newlist',page=p) }}">{{ p }}</a></li>
                                        {% endif %}
                                {% endfor %}


                                {% else %}
                                    {%  if page_now-2 >0 %}
                                        <li><a href="{{ url_for('.newlist',page=page_now-2) }}">{{ page_now-2 }}</a></li>
                                    {% endif %}
                                    {% if  page_now-1 >0  %}
                                        <li><a href="{{ url_for('.newlist',page=page_now-1) }}">{{ page_now-1 }}</a></li>
                                    {% endif %}
                                        <li ><a style="background-color: darkgray;opacity: 0.7;color: black" href="{{ url_for('.newlist',page=page_now) }}">{{ page_now }}</a></li>
                                    {% if (page_count-page_now) >1  %}
                                        <li><a href="{{ url_for('.newlist',page=page_now+1) }}">{{ page_now+1 }}</a></li>
                                    {% endif %}
                                    {% if (page_count - page_now) >2 %}
                                        <li><a href="{{ url_for('.newlist',page=page_now+1) }}">{{ page_now+2 }}</a></li>
                                    {% endif %}
                            {% endif %}

                        {#下一页#}
                            {%  if pagination.has_next  %}
                                <li><a href="{{ url_for('.newlist',page=pagination.next_num) }}">&raquo;</a></li>
                            {% endif %}
                                      <li><span style="color: black">页数 ( {{ page_now }}/{{ page_count }} )</span></li>

                        </ul>
            </nav>
        </div>
        <div style="text-align:center;">
            <ul id="example" style="cursor: pointer;"></ul>
        </div>
    <script src="{{ url_for('static',filename='js/bootstrap-paginator.js') }}"></script>

</div>
<!-- ##########主体（end）########## -->
{% endblock %}
